{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}

<div class="p-3">
	<form class="layui-form gg-form-bar border-t border-x">
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
		</div>
	</form>
	<table class="layui-hide" id="bank_card" lay-filter="bank_card"></table>
</div>

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
	</div>
</script>

<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
</script>

{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function feiniaoInit() {
		var table = layui.table,tool = layui.tool, form = layui.form;
		layui.pageTable = table.render({
			elem: '#bank_card',
			title: '银行卡列表',
			toolbar: '#toolbarDemo',
			url: '{:url("bank_card/datalist")}',
			page: true,
			limit: 20,
			cols: [
				[
				{
					fixed: 'left',
					field: 'id',
					title: '编号',
					align: 'center',
					width: 80
				},{
					field: 'card_no',
					title: '卡号',
					align: 'center',
					width: 250
				},{
					field: 'nickname',
					title: '用户',
					align: 'center',
					width: 200
				},{
					field: 'bank_name',
					title: '银行名称',
					align: 'center',
					width: 100
				},{
					field: 'card_image',
					title: '卡片图片',
					align: 'center',
					width: 100,
					templet:function(d) {
						return d.card_image ? '<img src="' + d.card_image + '" width="80" onclick="showBigImage(this)">' : '--';
					}
				},{
					field: 'bank_address',
					title: '银行地址',
					align: 'center',
					width: 300
				},{
					field: 'full_name',
					title: '卡主姓名',
					align: 'center',
					width: 100
				},{
					field: 'mobile',
					title: '卡主电话',
					align: 'center',
					width: 100
				},{
					field: 'status',
					title: '卡片状态',
					align: 'center',
					width: 100,
					templet:function(d) {
						return parseInt(d.status) === 1 ? '<i class="layui-icon layui-icon-ok" style="color: #16b777;"></i>' : '<i class="layui-icon layui-icon-close"></i>';
					}
				},{
					field: 'auth_status',
					title: '认证状态',
					align: 'center',
					width: 100,
					templet:function(d) {
						return parseInt(d.auth_status) === 1 ? '<i class="layui-icon layui-icon-ok" style="color: #16b777;"></i>' : '<i class="layui-icon layui-icon-close"></i>';
					}
				},{
					field: 'remark',
					title: '备注',
					align: 'center',
					width: 100,
					templet:function(d) {
						return d.remark ? d.remark : '--';
					}
				},{
					field: 'create_time',
					title: '添加时间',
					align: 'center',
					width: 150
				},{
					field: 'update_time',
					title: '更新时间',
					align: 'center',
					width: 150
				},
				{
					fixed: 'right',
					field: 'right',
					title: '操作',
					toolbar: '#barDemo',
					width: 100,
					align: 'center'
				}				
				]
			]
		});
		
		//监听表头工具栏事件
		table.on('toolbar(bank_card)', function(obj){
			if (obj.event === 'add') {
				tool.side("{:url('bank_card/add')}");
				return false;
			}
		});

		window.showBigImage = function (e) {
			layer.open({
				type: 1,
				title: false,
				closeBtn: true,
				shadeClose: true, //点击阴影关闭
				area: [$(e).width + 'px', $(e).height + 'px'], //宽高
				content: "<img src=" + $(e).attr('src') + " />"
			});
		};

		//监听表格行工具事件
		table.on('tool(bank_card)', function(obj) {
			var data = obj.data;
			if (obj.event === 'read') {
				tool.side('{:url("bank_card/read")}?id='+obj.data.id);
			}
			else if (obj.event === 'edit') {
				tool.side('{:url("bank_card/edit")}?id='+obj.data.id);
			}
			else if (obj.event === 'del') {
				layer.confirm('确定要删除该记录吗?', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("{:url('bank_card/del')}", { id: data.id }, callback);
					layer.close(index);
				});
			}
			return false;
		});

		//监听搜索提交
		form.on('submit(searchform)', function(data) {
			layui.pageTable.reload({
				where: {
					keywords: data.field.keywords
				},
				page: {
					curr: 1
				}
			});
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->